#include <stdio.h>
#include <stdlib.h>

//https://www.nowcoder.com/practice/36d5dfddc22c4f5b88a5b2a9de7db343?tpId=290&tqId=320958&ru=%2Fexam%2Foj%2Fta&qru=%2Fta%2Fbeginner-programmers%2Fquestion-ranking&sourceUrl=%2Fexam%2Foj%2Fta%3FtpId%3D290

typedef struct Matrix {
    int N;
    int Mat[0];
}Matrix;

int main() {
    int n = 0;
    scanf("%d", &n);
    //开辟柔性数组
    Matrix *arr = (Matrix *) malloc(sizeof(Matrix) + n * n * sizeof(int));
    if (arr == NULL) {
        perror("堆区开辟空间失败");
    }
    arr->N = n * n;
    //柔性数组的使用
    int i = 0;
    int j = 0;
    int layer = 1;
    for (int count = 0; count < n / 2 + n % 2; count++, layer++, i++, j++) {
        for (; i < n - layer; i++) {
            scanf("%d", &arr->Mat[i + n * j]);
        }
        for (; j < n - layer; j++) {
            scanf("%d", &arr->Mat[i + n * j]);
        }
        for (; i >= layer; i--) {
            scanf("%d", &arr->Mat[i + n * j]);
        }
        for (; j >= layer; j--) {
            scanf("%d", &arr->Mat[i + n * j]);
        }
    }
    if (i--, j--, n % 2) {
        scanf("%d", &arr->Mat[i + n * j]);
    }
    for (int k = 1; k <= arr->N; k++) {
        printf("%2d ", arr->Mat[k - 1]);
        if (k % n == 0) {
            printf("\n");
        }
    }
    //释放柔性数组
    free(arr);
    arr = NULL;
    return 0;
}